package com.choosefine.base.attendance.server.listener

import com.choosefine.base.attendance.server.record.AttendanceRecord
import com.choosefine.base.attendance.server.record.AttendanceRecordDao
import com.fasterxml.jackson.databind.ObjectMapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.jms.annotation.JmsListener
import org.springframework.stereotype.Component


/**
 * Created by 邱鹏 on 2017/8/30.
 */
@Component
class ConsumerListener {
    @Autowired lateinit var jsonObjectMapper: ObjectMapper
    @Autowired lateinit var attendanceRecordDao: AttendanceRecordDao
    @JmsListener(destination = "uploadAttendanceRecord")
    fun receiveQueue(text: String) {
        var attendance=jsonObjectMapper.readValue(text, AttendanceRecord::class.java)
        attendanceRecordDao.insert(attendance)
    }

}
